/*
    This file is part of SQLiteGTK, written by Aly Hirani

    SQLiteGTK is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    SQLiteGTK is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with SQLiteGTK.  If not, see <http://www.gnu.org/licenses/>.
*/

#include "include.h"
#include "main_window_menu_file.h"
#include "util.h"
#include "main_window.h"
#include "main_window_notebook.h"
#include "main_window_sqlite.h"

void
main_window_menu_file_new_activate_cb(GObject *object, gpointer user_data)
{
	/*
	g_assert(object != NULL);
	g_assert(user_data != NULL);
	
	GtkBuilder *builder = GTK_BUILDER(user_data);
	g_assert(builder != NULL);
	
	GtkAction *menu_file_close = GTK_ACTION(gtk_builder_get_object(builder, "menu_file_close"));
	g_assert(menu_file_close != NULL);
	
	GtkNotebook *notebook = GTK_NOTEBOOK(gtk_builder_get_object(builder, "editor_notebook"));
	g_assert(notebook != NULL);
	
	gtk_action_set_sensitive(menu_file_close, gtk_notebook_get_current_page(notebook) != 0);
	*/
}

void
main_window_menu_file_open_activate_cb(GObject *object, gpointer user_data)
{
}

void
main_window_menu_file_quit_activate_cb(GObject *object, gpointer user_data)
{
	gtk_widget_destroy(GTK_WIDGET(gtk_builder_get_object(GTK_BUILDER(user_data), "main_window")));
}

void
main_window_menu_file_activate_cb(GObject *object, gpointer user_data)
{
	GtkBuilder *builder;
	GtkAction *close_menu;

	g_assert(user_data);
	builder = GTK_BUILDER(user_data);
	g_assert(builder);

	close_menu = GTK_ACTION(gtk_builder_get_object(builder, "menu_file_close"));
	g_assert(close_menu);

	gtk_action_set_sensitive(close_menu, main_window_notebook_is_active_page_type(main_window_notebook_get_notebook_from_builder(builder), MWNPT_EDITOR));
}

void
main_window_menu_file_new_database(GObject *object, gpointer user_data)
{
	/*
	g_assert(user_data != NULL);
	
	GtkBuilder *builder = GTK_BUILDER(user_data);
	g_assert(builder != NULL);
	
	GObject *window = gtk_builder_get_object(builder, "main_window");
	g_assert(window != NULL);
	
	gchar *file_path = show_save_file_dialog(GTK_WINDOW(window), "New SQLite Database", "SQLite3 Database", "application/x-sqlite3", NULL);
	
	if(file_path)
	{
		main_window_sqlite_open_database(builder, file_path);
		
		g_free (file_path);
	}
	*/
}

void
main_window_menu_file_open_database(GObject *object, gpointer user_data)
{
	/*
	g_assert(user_data != NULL);
	
	GtkBuilder *builder = GTK_BUILDER(user_data);
	g_assert(builder != NULL);
	
	GObject *window = gtk_builder_get_object(builder, "main_window");
	g_assert(window != NULL);
	
	gchar *file_path = show_open_file_dialog(GTK_WINDOW(window), "Open SQLite Database", "SQLite3 Database", "application/x-sqlite3", NULL);
	
	if(file_path)
	{
		main_window_sqlite_open_database(builder, file_path);
		
		g_free (file_path);
	}
	*/
}

void
main_window_menu_file_close_activate_cb(GObject *object, gpointer user_data)
{
	/*
	g_assert(object != NULL);
	g_assert(user_data != NULL);
	
	GtkBuilder *builder = GTK_BUILDER(user_data);
	g_assert(builder != NULL);
	
	log_verbose("Stub: main_window_menu_file_close");
	
	// Do stuff here
	*/
}

